<template>
  <div class="afterInvestDel-page">
    <pubChunk>
      <div slot="title">
        <span class="title">{{ info.classfyName }}</span>
        <el-tooltip
          v-if="info.mark"
          popper-class="tit-tip"
          :open-delay="500"
          :content="info.mark"
          placement="right"
        >
          <i class="el-icon-document fontdoc"></i>
        </el-tooltip>
      </div>
      <div slot="headLeft" style="width: 194px">
        <el-button size="small" type="primary" @click="goContrast">
          <i class="iconfont icon-jia"></i>
          去对比
        </el-button>
        <el-button size="small" @click="refreshPage">
          <i class="iconfont icon-shuaxin"></i>
          刷新
        </el-button>
      </div>
      <div class="head3">
        <div class="head-content flex">
          <div class="left">
            <el-row :gutter="12">
              <el-col :span="8">
                <div class="fromLine">
                  <div class="label label-line2">
                    <p>单位净值：</p>
                    <p class="fs12 tip">
                      {{ info.classifyNetWorthTime | parseTime }}
                    </p>
                  </div>
                  <div class="fromLine-content fzBig">
                    {{ info.classifyNetWorth }}
                  </div>
                </div>
              </el-col>
              <el-col :span="7">
                <div class="fromLine">
                  <div class="label label-line2">
                    <p>今年以来收益率：</p>
                    <p class="fs12 tip">
                      截止至{{ info.classifyNetWorthTime | parseTime }}
                    </p>
                  </div>
                  <div class="fromLine-content fzBig">
                    <span
                      v-if="
                        info.classifyNetWorthExtendBeans &&
                        info.classifyNetWorthExtendBeans[0].incomeRate
                      "
                      :class="
                        info.classifyNetWorthExtendBeans[0].incomeRate > 0
                          ? 'positiveFc1'
                          : 'negativeFc1'
                      "
                    >
                      {{
                        info.classifyNetWorthExtendBeans[0].incomeRate
                          | toFixed2
                      }}%
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
              <el-col :span="9">
                <div class="fromLine">
                  <div
                    class="label label-line2"
                    style="width: 138.69px; text-align: right"
                  >
                    <p>成立以来收益率：</p>
                    <p class="fs12 tip tof">
                      成立日期：{{
                        info.classifyNetWorthBean &&
                        info.classifyNetWorthBean.startDate | parseTime
                      }}
                    </p>
                  </div>
                  <div class="fromLine-content fzBig">
                    <span
                      v-if="
                        info.classifyNetWorthExtendBeans &&
                        info.classifyNetWorthExtendBeans[7].incomeRate
                      "
                      :class="
                        info.classifyNetWorthExtendBeans[7].incomeRate > 0
                          ? 'positiveFc1'
                          : 'negativeFc1'
                      "
                    >
                      {{
                        info.classifyNetWorthExtendBeans[7].incomeRate
                          | toFixed2
                      }}%
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="12" style="margin-top: 16px">
              <el-col :span="8">
                <div class="fromLine">
                  <div class="label" style="width: 78.69px; text-align: right">
                    累计净值：
                  </div>
                  <div class="fromLine-content fw">
                    {{ info.classifyNetWorth }}
                  </div>
                </div>
              </el-col>
              <el-col :span="7">
                <div class="fromLine">
                  <div class="label" style="width: 112px; text-align: right">
                    近3月收益率：
                  </div>
                  <div class="fromLine-content fw">
                    <span
                      v-if="
                        info.classifyNetWorthExtendBeans &&
                        info.classifyNetWorthExtendBeans[2].incomeRate
                      "
                      :class="
                        info.classifyNetWorthExtendBeans[2].incomeRate > 0
                          ? 'positiveFc1'
                          : 'negativeFc1'
                      "
                    >
                      {{
                        info.classifyNetWorthExtendBeans[2].incomeRate
                          | toFixed2
                      }}%
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
              <el-col :span="9">
                <div class="fromLine">
                  <div class="label" style="width: 138.69px; text-align: right">
                    年化收益率：
                  </div>
                  <div class="fromLine-content fw">
                    <span
                      v-if="info.riskIndicatorsBean"
                      :class="
                        info.riskIndicatorsBean.annualizedIncomeRate > 0
                          ? 'positiveFc1'
                          : 'negativeFc1'
                      "
                    >
                      {{
                        info.riskIndicatorsBean.annualizedIncomeRate | toFixed2
                      }}%
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="12">
              <el-col :span="8">
                <div class="fromLine">
                  <div class="label" style="width: 78.69px; text-align: right">
                    复权净值：
                  </div>
                  <div class="fromLine-content fw">
                    {{ info.classifyNetWorth }}
                  </div>
                </div>
              </el-col>
              <el-col :span="7">
                <div class="fromLine">
                  <div class="label" style="width: 112px; text-align: right">
                    近6月收益率：
                  </div>
                  <div class="fromLine-content fw">
                    <span
                      v-if="
                        info.classifyNetWorthExtendBeans &&
                        info.classifyNetWorthExtendBeans[3].incomeRate
                      "
                      :class="
                        info.classifyNetWorthExtendBeans[3].incomeRate > 0
                          ? 'positiveFc1'
                          : 'negativeFc1'
                      "
                    >
                      {{
                        info.classifyNetWorthExtendBeans[3].incomeRate
                          | toFixed2
                      }}%
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
              <el-col :span="9">
                <div class="fromLine">
                  <div class="label" style="width: 138.69px; text-align: right">
                    夏普比率：
                  </div>
                  <div class="fromLine-content fw">
                    <span v-if="info.riskIndicatorsBean">
                      {{ info.riskIndicatorsBean.sharpeRate | toFixed2 }}
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-row :gutter="12">
              <el-col :span="8"><div style="height: 22px"></div></el-col>
              <el-col :span="7">
                <div class="fromLine">
                  <div class="label" style="width: 112px; text-align: right">
                    近1年收益率：
                  </div>
                  <div class="fromLine-content fw">
                    <span
                      v-if="
                        info.classifyNetWorthExtendBeans &&
                        info.classifyNetWorthExtendBeans[4].incomeRate
                      "
                      :class="
                        info.classifyNetWorthExtendBeans[4].incomeRate > 0
                          ? 'positiveFc1'
                          : 'negativeFc1'
                      "
                    >
                      {{
                        info.classifyNetWorthExtendBeans[4].incomeRate
                          | toFixed2
                      }}%
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
              <el-col :span="9">
                <div class="fromLine">
                  <div class="label" style="width: 138.69px; text-align: right">
                    最大回撤：
                  </div>
                  <div class="fromLine-content fw">
                    <span v-if="info.riskIndicatorsBean">
                      {{ info.riskIndicatorsBean.maximumDrawdownRate }}
                    </span>
                    <span v-else>/</span>
                  </div>
                </div>
              </el-col>
            </el-row>
          </div>
          <div class="right">
            <div class="fromLine">
              <div class="label label-line2">
                <p>资产金额：</p>
                <p class="fs12 tip tof">单位：万元</p>
              </div>
              <div class="fromLine-content fzBig">{{ info.initMoney }}</div>
            </div>
            <div class="fromLine" style="margin-top: 15px">
              <div class="label">开始日期：</div>
              <div class="fromLine-content fw">
                {{
                  info.classifyNetWorthBean &&
                  info.classifyNetWorthBean.startDate | parseTime
                }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </pubChunk>
  </div>
</template>
<script>
import { randomNum } from "@/utils/pro";
import pubChunk from "@/components/investComn/pubChunk.vue";
import mixin from "./mixins";
import { getClassifyHeadDetail } from "@/api/groupManage";
// import { parseTime, deepClone } from '@/utils'

export default {
  mixins: [mixin],
  components: {
    pubChunk,
  },
  data() {
    return {
      listLoading: false,
      info: {},
      allStrategyVisible: false,
    };
  },
  props: {
    info_parent: {
      type: Object || Array,
    },
  },
  mounted() {
    this.getInfo();
  },
  methods: {
    // selctInvestNameHandle(row) {
    //   this.$emit('update:realquery', row)
    // },
    getInfo() {
      getClassifyHeadDetail({ classifyId: this.classifyId }).then((res) => {
        console.log("详情", res);
        this.info = res.body;
        // console.log('投资详情-header', values[0])
        // console.log('投资详情-content', values[1])
        // this.info = {
        //   ...this.info,
        //   ...values[0].body,
        //   ...values[1].body.strategyInfoVo,
        //   riskIndicatorsBean: values[1].body.riskIndicatorsBean,
        //   netWorthDetialBean: values[1].body.netWorthDetialBean,
        // }
        this.$emit("update:info_parent", this.info);
      });
    },
    goContrast() {
      const res_list = [
        {
          id: this.strategyId,
          name: this.info.strategyName,
          type: 1,
        },
      ];
      const id = randomNum(6);
      this.$router.push({
        path: `/policyManage/contrast/${id}`,
        query: {
          list: JSON.stringify(res_list),
          one: 1,
        },
      });
    },
    refreshPage() {
      const view = this.$route;
      this.$store.dispatch("tagsView/delCachedView", view).then(() => {
        const { fullPath } = view;
        this.$nextTick(() => {
          this.$router.replace({
            path: "/redirect" + fullPath,
          });
        });
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.afterInvestDel-page {
  .title {
    font-size: 26px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #262626;
    display: inline-block;
    margin-right: 10px;
  }
  .icon-jia {
    font-size: 12px;
    margin-right: 6px;
  }
  .icon-shuaxin {
    font-size: 14px;
    margin-right: 6px;
  }
}
</style>
